#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: 
@time: 2024/3/2 12:01 AM
@Function: 存放asset页面对象
"""
import re
import time

import allure
import pytest
from allure import attach
from allure_commons.types import AttachmentType
from utils.configParse import config
from playwright.sync_api import Page, expect
from repository import assetObject, addBimAssetObject, assetListObject, assetSelectObject, assetMoreObject, \
    assetGisBimObject, assetGisSelectObject, AssetBimAssembleyObject, AssetQueryObject, AssetGisListObject


class XbaseException(Exception):
    def __init__(self, msg):
        self.msg = msg


class AssetPage:
    def __init__(self, page: Page):
        self.page = page
        self.result_text_list = []
        self.asset_manage_loc = page.locator(assetObject.asset_manage)
        page.locator(assetObject.asset_manage)
        self.gis_asset_loc = page.locator(assetObject.gis_asset)
        # addBimAssetPage
        self.add_bim_asset_button_loc = page.locator(addBimAssetObject.add_bim_asset_button)
        self.select_model_loc = page.locator(addBimAssetObject.select_model)
        self.input_asset_name_loc = page.get_by_placeholder(addBimAssetObject.input_asset_name)
        self.input_asset_desc_loc = page.get_by_placeholder(addBimAssetObject.input_asset_desc)
        self.add_button_loc = page.locator(addBimAssetObject.add_button)
        self.select_model_list_loc = page.locator(addBimAssetObject.select_model_list)
        self.select_model_list_info_loc = page.locator(addBimAssetObject.select_model_list_info)
        self.selec_model_list_folder_info_loc = page.locator(addBimAssetObject.selec_model_list_folder_info)
        self.select_model_list_box_loc = page.locator(addBimAssetObject.select_model_list_box)
        # assetListPage
        self.asset_lists_loc = page.locator(assetListObject.asset_lists)
        self.asset_status_loc = page.locator(assetListObject.asset_status)
        self.asset_convert_file_name_loc = page.locator(assetListObject.asset_convert_file_name)
        self.asset_convert_confirm_loc = page.locator(assetListObject.asset_convert_confirm)
        self.asset_convert_cancel_loc = page.locator(assetListObject.asset_convert_cancel)
        self.asset_reconver_asm_box_text_loc = page.locator(assetListObject.asset_reconver_asm_box_text)
        self.asset_reconver_asm_confirm_loc = page.locator(assetListObject.asset_reconver_asm_confirm)
        self.asset_reconver_asm_cancel_loc = page.locator(assetListObject.asset_reconver_asm_cancel)
        # 资产管理-更多中的下拉内容
        self.asset_more_loc = page.locator(assetListObject.asset_more)

        # 资产管理-查询设置

        # 资产管理-资产搜索中
        self.asset_select_input_loc = page.get_by_placeholder(assetSelectObject.asset_select_input)
        self.asset_select_button_loc = page.get_by_role('button', name=assetSelectObject.asset_select_button)
        self.asset_select_reset_loc = page.locator(assetSelectObject.asset_select_reset)
        self.asset_select_setting_loc = page.locator(assetSelectObject.asset_select_setting)
        self.asset_select_setting_selectAll_input_loc = page.locator(
            assetSelectObject.asset_select_setting_selectAll_input)
        self.asset_select_setting_confirm_loc = page.locator(assetSelectObject.asset_select_setting_confirm)
        self.asset_select_selection_loc = page.locator(assetSelectObject.asset_select_selection)
        self.asset_select_setting_input_loc = page.locator(assetSelectObject.asset_select_setting_name)
        # 资产管理-资产更多
        self.asset_more_box_loc = page.locator(assetMoreObject.asset_more_box)
        self.asset_more_list_loc = page.locator(assetMoreObject.asset_more_list)
        self.asset_more_detail_loc = page.locator(assetMoreObject.asset_detail)
        self.asset_more_detail_box_loc = page.locator(assetMoreObject.asset_detail_box)
        self.asset_more_detail_box_text_info_loc = page.locator(assetMoreObject.asset_detail_box_text_info)
        self.asset_more_detail_box_button_loc = page.locator(assetMoreObject.asset_detail_box_button)
        self.asset_more_share_loc = page.locator(assetMoreObject.asset_share)
        self.asset_more_share_box_loc = page.locator(assetMoreObject.asset_share_box)
        self.asset_more_share_box_text_loc = page.locator(assetMoreObject.asset_share_box_text)
        self.asset_more_share_box_shareContent_loc = page.locator(assetMoreObject.asset_share_box_shareContent)
        self.asset_more_share_box_ShareValidityPeriod_loc = page.locator(
            assetMoreObject.asset_share_box_ShareValidityPeriod)
        self.asset_more_share_box_Password_loc = page.locator(assetMoreObject.asset_share_box_Password)
        self.asset_more_share_box_periodOfValidity_oneDay_loc = page.locator(
            assetMoreObject.asset_share_periodOfValidity_oneDay)
        self.asset_more_share_box_periodOfValidity_sevenDay_loc = page.locator(
            assetMoreObject.asset_share_periodOfValidity_sevenDay)
        self.asset_more_share_box_periodOfValidity_foreverDay_loc = page.locator(
            assetMoreObject.asset_share_periodOfValidity_foreverDay)
        self.asset_more_share_set_nopassword_loc = page.locator(assetMoreObject.asset_share_set_nopassword)
        self.asset_more_share_set_havapassword_loc = page.locator(assetMoreObject.asset_share_set_havapassword)
        self.asset_more_share_set_password_loc = page.get_by_placeholder(assetMoreObject.asset_share_set_password)
        self.asset_more_share_success_box_loc = page.locator(assetMoreObject.asset_share_success_box)
        self.asset_more_share_box_confirm_button_loc = page.get_by_role('button',
                                                                        name=assetMoreObject.asset_share_box_confirm_button)
        self.asset_more_share_box_cancel_button_loc = page.get_by_role('button',
                                                                       name=assetMoreObject.asset_share_box_cancel_button)
        self.asset_more_share_box_close_button_loc = page.get_by_role('button',
                                                                      name=assetMoreObject.asset_share_box_close_button)
        self.asset_more_render_info_loc = page.locator(assetMoreObject.asset_render_info)
        self.asset_more_render_info_box_loc = page.locator(assetMoreObject.asset_render_info_box)
        self.asset_more_render_info_text_box_loc = page.locator(assetMoreObject.asset_render_info_text_box)
        self.asset_more_render_info_box_button_loc = page.locator(assetMoreObject.asset_render_info_box_button)
        self.asset_more_rename_loc = page.locator(assetMoreObject.asset_rename)
        self.asset_more_rename_box_loc = page.locator(assetMoreObject.asset_rename_box)
        self.asset_more_rename_box_input_loc = page.get_by_placeholder(assetMoreObject.asset_rename_box_input)
        self.asset_more_rename_box_confirm_loc = page.get_by_role('button',
                                                                  name=assetMoreObject.asset_rename_box_confirm)
        self.asset_more_rename_box_cancel_loc = page.get_by_role('button',
                                                                 name=assetMoreObject.asset_rename_box_cancel)
        self.asset_delete_loc = page.locator(assetMoreObject.asset_delete)
        self.asset_delete_box_loc = page.locator(assetMoreObject.asset_delete_box)
        self.asset_delete_box_text_loc = page.locator(assetMoreObject.asset_delete_box_text)
        self.asset_delete_confirm_button_loc = page.get_by_role('button',
                                                                name=assetMoreObject.asset_delete_confirm_button)
        self.asset_delete_cancel_button_loc = page.get_by_role('button',
                                                               name=assetMoreObject.asset_delete_cancel_button)
        # bim资产装配
        self.asset_bim_asm_button_loc = page.get_by_role('button', name=AssetBimAssembleyObject.asset_bim_asm_button)
        self.asset_bim_asm_box_loc = page.locator(AssetBimAssembleyObject.asset_bim_asm_box)
        self.asset_bim_asm_box_search_loc = page.locator(AssetBimAssembleyObject.asset_bim_asm_box_search)
        self.asset_bim_asm_box_assName_loc = page.locator(AssetBimAssembleyObject.asset_bim_asm_box_assName)
        self.asset_bim_asm_box_cancel_loc = page.get_by_role('button',
                                                             name=AssetBimAssembleyObject.asset_bim_asm_box_cancel)
        self.asset_bim_asm_box_confirm_loc = page.get_by_role('button',
                                                              name=AssetBimAssembleyObject.asset_bim_asm_box_confirm)
        self.asset_bim_asm_box_model_checkbox_loc = page.locator(
            AssetBimAssembleyObject.asset_bim_asm_box_model_checkbox)

        # 切换gis和bim的tab
        self.asset_gis_tab_loc = page.locator(assetGisBimObject.asset_gis_tab)
        self.asset_bim_tab_loc = page.locator(assetGisBimObject.asset_bim_tab)
        # gis相关页面对象操作
        self.gis_asset_more_loc = page.locator(AssetGisListObject.gis_asset_more)

    @allure.step('进入资产管理模块')
    def navigate(self, envir):
        # 测试环境
        try:
            if envir == "test":
                self.page.goto(
                    config.get_ini_login_url('xbasetest_url') + '/console/asset-micro/manage')
                self.asset_manage_loc.wait_for(state="visible")
            # stage环境
            elif envir == "stage":
                self.page.goto(config.get_ini_login_url('xbasestage_url') + '/console/appInfo-assets')
        except Exception as e:
            print('navigate方法存在问题，路径可能更新了')

    # @allure.step('在资产搜索框中输入搜索内容')
    # def fill_search_asset(self, search_name):
    # 需要取消，重复了
    # self.search_asset_loc.fill(search_name)

    # @allure.step('点击搜索按钮')
    # def click_search_button(self):
    # 需要取消，重复了
    # self.search_button_loc.click()

    @allure.step('点击添加bim模型资产按钮')
    def click_add_bim_button(self):
        self.add_bim_asset_button_loc.click()

    @allure.step('下拉选择模型资产')
    def select_model(self, model_file_index=None):
        """
        针对bim资产的添加资产操作，在选择模型下拉框做相关操作(目前这个方法只固定判断第一行数据)
        注意：此方法有局限，暂时只能用于我个人，其他人调用不具备通用性
        :return:
        """
        self.select_model_loc.click()
        self.select_model_list_box_loc.wait_for(state='visible')
        # 获取添加bim资产-选择模型下拉框中第一个模型或文件夹信息
        select_model_folder = self.selec_model_list_folder_info_loc.inner_text()
        is_model_file = re.search(r".+\\.ifc$", select_model_folder)
        if is_model_file is not True:
            print("查到的文件夹名称为：", select_model_folder)
            # 判断选择模型第一个元素是否走多层级转换
            if re.match(r'^rvt多层级转换', select_model_folder):
                self.select_model_list_info_loc.click()
                print("选择多层级转换，展开文件夹")
                time.sleep(2)
                text_element = self.page.locator(
                    '//div[contains(@class,"sms-tree-treenode-switcher-close")][{}]//span[@class="treeNodeName"]'.format(
                        model_file_index))
                result_text = text_element.inner_text()
                print("result_text--->", result_text)
                if re.search(r'^红房子建筑级|红房子空间级|红房子构件级',
                             result_text) and result_text not in self.result_text_list:
                    self.result_text_list.append(result_text)
                    print("result_text_list--->", self.result_text_list)
                    text_element.click()
            else:
                # 如果没有匹配到rvt多层级转换文件夹，那就代表只是普通的添加bim资产，目前只是添加一个ifc文件
                self.select_model_list_info_loc.hover()
                self.select_model_list_info_loc.click()
                # 添加模型下拉框如果是文件夹，查看文件夹里的文件名称
                model_folder_file_name = self.page.locator(
                    "//div[@class='sms-tree-list-holder']//div[contains(@class,'sms-tree-treenode')][2]//span[@class='treeNodeName']").inner_text()
                is_model_folder_file_name = re.search(r".[a-zA-Z]$", model_folder_file_name)
                if is_model_folder_file_name:
                    self.page.locator(
                        "//div[@class='sms-tree-list-holder']//div[contains(@class,'sms-tree-treenode')][2]//span[@class='treeNodeName']").click()
        else:
            # 判断走文件判断
            self.page.locator(
                "//div[@class='sms-tree-list-holder']//div[contains(@class,'sms-tree-treenode')][2]//span[@class='treeNodeName']").click()

    def estimate_asset_file_status(self):
        pass

    @allure.step('在添加资产模型的输入框中输入资产名称')
    def fill_asset_name(self, asset_name):
        self.input_asset_name_loc.fill(asset_name)

    @allure.step('在添加资产描述的输入框中输入资产描述')
    def fill_asset_desc(self, asset_desc):
        self.input_asset_desc_loc.fill(asset_desc)

    @allure.step('添加bim资产主流程')
    def click_add_info_succ_button(self, asset_name, asset_desc, model_file_index=None):
        self.click_add_bim_button()
        self.select_model(model_file_index=model_file_index)
        self.fill_asset_name(asset_name)
        self.fill_asset_desc(asset_desc)
        self.add_button_loc.click()

    @allure.step('点击资产转换')
    def click_asset_convert(self, asset_list_index, convert_text):
        try:
            operation_contexts = self.page.query_selector_all(
                '//tbody[@class="sms-table-tbody"]/tr[{}]/td[8]/span/span'.format(asset_list_index))
            for operation in range(1, len(operation_contexts) + 1):
                operation_conver = self.page.locator(
                    '//tbody[@class="sms-table-tbody"]/tr[{}]/td[8]/span/span[{}]'.format(asset_list_index,
                                                                                          operation)).inner_text()
                if convert_text == operation_conver:
                    self.page.locator(
                        '//tbody[@class="sms-table-tbody"]/tr[{}]/td[8]/span/span[{}]'.format(asset_list_index,
                                                                                              operation)).click()
        except:
            raise XbaseException('click_asset_convert方法出现异常，请查看')

    @allure.step('点击确认按钮来转换资产')
    def asset_convert_confirm_cancel_button(self, is_convert, convert_text):
        asset_numbers = self.asset_lists_loc.count()
        for x in range(1, asset_numbers + 1):
            asset_conver_file_name = self.asset_convert_file_name_loc.inner_text()
            asset_status = self.page.locator(
                '//tbody[@class="sms-table-tbody"]/tr[{}]/td[5]//span'.format(x)).inner_text()
            if asset_status in ['待转换', '转换失败', '转换成功']:
                self.click_asset_convert(x, convert_text)
                if is_convert is True:
                    self.asset_convert_confirm_loc.wait_for(state="visible")
                    self.asset_convert_confirm_loc.click()
                    # 这里判断是否出现重新转换时的转换提示：资产参与了资产装配/场景，继续转换将影响使用，是否继续？
                    try:
                        asset_reconver_bot_result = self.page.query_selector(
                            assetListObject.asset_reconver_asm_box_text)
                        print("asset_reconver_bot_result==>", asset_reconver_bot_result)
                        if asset_reconver_bot_result:
                            reconver_asm_box_text = self.asset_reconver_asm_box_text_loc.inner_text()
                            if reconver_asm_box_text:
                                self.asset_reconver_asm_confirm_loc.click()
                                self.asset_convert_confirm_loc.wait_for(state='hidden')
                    except Exception as e:
                        print(f"资产未参与资产装配/场景，该弹框没有出现{e}")
                    while True:
                        asset_status = self.page.locator(
                            '//tbody[@class="sms-table-tbody"]/tr[{}]/td[5]//span'.format(x)).inner_text()
                        asset_after_convert_file_name = self.asset_convert_file_name_loc.inner_text()
                        if asset_status == '转换成功' and asset_conver_file_name == asset_after_convert_file_name:
                            break
                else:
                    self.asset_convert_cancel()
                    break
            print('资产状态为:{}'.format(asset_status))
            break

    @allure.step('点击取消按钮来取消转换')
    def asset_convert_cancel(self):
        self.asset_convert_cancel_loc.wait_for(state="visible")
        self.asset_convert_cancel_loc.click()

    @allure.step('在资产管理搜索框中输入搜索内容')
    def asset_query_input(self, asset_info):
        """
        对应资产管理中搜索的input输入框
        :return:
        """
        self.asset_select_input_loc.fill(asset_info)

    @allure.step('点击查询按钮')
    def asset_query_button(self):
        """
        对应资产管理中搜索的查询按钮
        :return:
        """
        self.asset_select_button_loc.click()
        asset_list_numbers = self.page.locator('//tbody[@class="sms-table-tbody"]/tr').count()
        assert asset_list_numbers >= 0

    @allure.step('重置资产搜索框内容')
    def asset_query_reset(self):
        """
        对应资产管理中搜索的重置
        :return:
        """
        self.asset_select_reset_loc.click()
        asset_list_numbers = self.page.locator('//tbody[@class="sms-table-tbody"]/tr').count()
        expect(self.asset_select_input_loc).to_have_value('')
        assert asset_list_numbers >= 1

    @allure.step('勾选查询设置中的内容')
    def asset_query_setting_box(self):
        """
        对应资产管理查询设置中的公共方法
        :return:
        """
        self.asset_select_setting_loc.click()
        expect(self.asset_select_setting_selectAll_input_loc).to_be_visible()
        self.asset_select_setting_selectAll_input_loc.click()
        self.asset_select_setting_selectAll_input_loc.click()

    @allure.step('依据资产状态来过滤资产列表数据')
    def asset_status_select(self, asset_status_info):
        """
        对应查询设置中选择资产状态，通过传递的资产状态来过滤资产列表数据
        :param asset_status_info:
        :return:
        """
        self.asset_select_selection_loc.click()
        asset_status_res = self.page.locator(AssetQueryObject.querySet_assetTypeAndStatus_content).count()
        for x in range(1, asset_status_res + 1):
            asset_status = self.page.locator(
                AssetQueryObject.querySet_assetTypeAndStatus_content + "[{}]".format(x)).inner_text()
            # expect(self.asset_status_selects_loc).to_contain_text(asset_status)
            if asset_status_info == asset_status:
                self.page.locator(AssetQueryObject.querySet_assetTypeAndStatus_content + "[{}]".format(x)).click()
                break

    # @allure.step('点击更多中的资产删除')
    # def click_asset_delete(self):
    #     self.asset_delete_loc.click()

    def asset_more_drop_down_box(self, asset_type):
        """
        对应判断资产列表更多下拉框是否出现-提取的公共方法
        :return:
        """
        if asset_type == 'bim':
            self.asset_more_loc.hover()
        elif asset_type == 'gis':
            self.gis_asset_more_loc.hover()
        self.page.wait_for_selector(assetMoreObject.asset_more_box, state="attached")
        # expect(self.asset_more_box_loc).to_be_visible(timeout=3000)

    @allure.step('利用查询设置中的内容进行资产搜索')
    def asset_query_setting_func(self, asset_query_select_name, asset_type='bim'):
        """
        针对资产管理查询设置重构成统一的方法
        功能：传入查询设置中的内容，来自动匹配对应的内容
        :return:
        """
        if asset_type != 'bim':
            self.asset_gis_tab_loc.click()
        self.asset_query_setting_box()
        asset_query_select_lists = self.asset_select_setting_input_loc.count()
        for x in range(1, asset_query_select_lists + 1):
            if asset_query_select_name == self.page.locator(
                    "//div[@class='sms-popover-inner']//div[@class='sms-popover-inner-content']//div[{}]/label/span[2]".format(
                        x)).inner_text():
                self.page.locator(
                    "//div[@class='sms-popover-inner']//div[@class='sms-popover-inner-content']//div[{}]/label/span[1]".format(
                        x)).click()
                break
        self.asset_select_setting_confirm_loc.click()
        # 查看列表的数量
        asset_list_numbers = self.page.locator('//tbody[@class="sms-table-tbody"]/tr').count()
        assert asset_list_numbers >= 0

    def asset_more_drop_down_list_func(self, asset_type, asset_more_list_name, asset_status):
        """
        获取资产列表更多选项下拉内容-公共方法
        :param asset_more_list_name: 传入在更多下拉内容中要选择的操作内容，比如：更多下拉框中的详情
        :return:
        """
        self.asset_more_drop_down_box(asset_type)
        asset_more_lists = self.asset_more_list_loc.count()
        for x in range(1, asset_more_lists + 1):
            if asset_type == 'bim' and x == 4 and asset_status == "转换成功":
                continue
            elif asset_type == 'bim' and x <= 4 and asset_status == "待转换":
                continue
            asset_more_list_content = self.page.locator(
                assetMoreObject.asset_more_list + "[{}]//span[@class='btn-active']".format(x)).inner_text()
            if asset_more_list_content.strip() == asset_more_list_name:
                self.page.locator(
                    assetMoreObject.asset_more_list + "[{}]//span[@class='btn-active']".format(x)).hover()
                self.page.locator(
                    assetMoreObject.asset_more_list + "[{}]//span[@class='btn-active']".format(x)).click()
                break

    @allure.step('选择资产列表更多中的详情信息')
    def asset_detail(self, asset_type, asset_more_list_name, asset_status):
        """
        对应资产管理更多中的资产详情
        :param asset_more_list_name:
        :return:
        """
        try:
            self.asset_more_drop_down_list_func(asset_type, asset_more_list_name, asset_status)
            self.page.wait_for_selector(assetMoreObject.asset_detail_box, state="attached")
            expect(self.asset_more_detail_box_loc).to_be_visible()
            if asset_type == "bim":
                expect(self.asset_more_detail_box_text_info_loc).to_have_text(
                    ["开始转换时间", "转换总时长", "转换状态", "资产描述"])
            elif asset_type == "gis":
                expect(self.asset_more_detail_box_text_info_loc).to_contain_text(
                    ["开始转换时间", "转换总时长", "资产类型", "转换状态", "资产描述"])
            self.asset_more_detail_box_button_loc.click()
        except Exception as e:
            print(f'出现异常：{e}')

    @allure.step('选择资产列表更多中的渲染信息')
    def asset_render_info(self, asset_type, asset_more_list_name, asset_status):
        """
        对应资产管理更多中的渲染信息
        :param asset_more_list_name:
        :return:
        """
        self.asset_more_drop_down_list_func(asset_type, asset_more_list_name, asset_status)
        self.page.wait_for_selector(assetMoreObject.asset_render_info_box, state="attached")
        expect(self.asset_more_render_info_box_loc).to_be_visible()
        expect(self.asset_more_render_info_text_box_loc).to_have_text(["资产ID", "渲染路径"])
        self.asset_more_render_info_box_button_loc.click()

    @allure.step('选择资产列表更多中的重命名')
    def asset_rename(self, asset_type, asset_more_list_name, asset_rename_info, asset_status):
        """
        对应资产管理更多中的重命名
        :param asset_more_list_name:
        :param asset_rename_info:
        :return:
        """
        self.asset_more_drop_down_list_func(asset_type, asset_more_list_name, asset_status)
        self.page.wait_for_selector(assetMoreObject.asset_rename_box, state="attached")
        self.asset_more_rename_box_input_loc.clear()
        self.asset_more_rename_box_input_loc.fill(asset_rename_info)
        self.asset_more_rename_box_confirm_loc.click()

    @allure.step('选择资产列表更多中的删除')
    def asset_delete(self, asset_type, asset_more_list_name, asset_status):
        """
        对应资产管理更多中的删除
        :param asset_more_list_name:
        :return:
        """
        self.asset_more_drop_down_list_func(asset_type, asset_more_list_name, asset_status)
        self.page.wait_for_selector(assetMoreObject.asset_delete_box, state="attached")
        expect(self.asset_delete_box_text_loc).to_have_text("此删除操作不可恢复，是否继续？")
        self.asset_delete_confirm_button_loc.click()

    @allure.step('设置资产分享中的有分享时效')
    def asset_share_precription(self, asset_type, asset_more_list_name, asset_status, share_validity_period=1):
        """
        对应资产管理更多中的分享-默认1天和无密码
        :param asset_more_list_name:
        :param share_validity_period:
        :return:
        """
        self.asset_more_drop_down_list_func(asset_type, asset_more_list_name, asset_status)
        self.page.wait_for_selector(assetMoreObject.asset_share_box, state="attached")
        expect(self.asset_more_share_box_shareContent_loc).to_contain_text('分享内容')
        expect(self.asset_more_share_box_ShareValidityPeriod_loc).to_contain_text('分享时效')
        expect(self.asset_more_share_box_Password_loc).to_contain_text('分享密码')
        if share_validity_period == 1:
            self.asset_more_share_box_periodOfValidity_oneDay_loc.click()
        elif share_validity_period == 7:
            self.asset_more_share_box_periodOfValidity_sevenDay_loc.click()
        else:
            self.asset_more_share_box_periodOfValidity_foreverDay_loc.click()

    @allure.step('设置资产分享中的分享密码')
    def asset_share_password(self, pwd_info, share_pwd='无'):
        """
        对应资产管理更多中的分享-设置分享密码
        :param pwd_info:
        :param share_pwd:
        :return:
        """
        if share_pwd == '有':
            self.asset_more_share_set_havapassword_loc.click()
            self.asset_more_share_set_password_loc.clear()
            self.asset_more_share_set_password_loc.fill(pwd_info)
        self.asset_more_share_box_confirm_button_loc.click()
        self.asset_more_share_box_close_button_loc.click()

    @allure.step('点击资产装配按钮')
    def asset_bim_asm_button(self):
        self.asset_bim_asm_button_loc.click()

    @allure.step('点击bim资产装配确定按钮')
    def asset_bim_asm_confirm_button(self):
        self.asset_bim_asm_box_confirm_loc.click()

    @allure.step('进行bim资产装配模型搜索')
    def asset_bim_asm_search_input(self, bim_search_name):
        self.asset_bim_asm_box_search_loc.fill(bim_search_name)

    @allure.step('装配bim资产')
    def asset_bim_assembly(self, assembly_name):
        self.asset_bim_asm_button()
        expect(self.asset_bim_asm_box_loc).to_be_visible()
        try:
            bim_asset_numbers = self.asset_bim_asm_box_model_checkbox_loc.count()
            if bim_asset_numbers >= 2:
                for x in range(1, bim_asset_numbers):
                    self.page.locator(
                        "//div[@class='main']//div[@class='sms-tree-list-holder-inner']/div[{}]//span[@class='sms-tree-checkbox']".format(
                            x)).click()
                    if x >= 2:
                        break
            else:
                print("<-资产装配弹框中的模型数据不够装配使用->")
        except Exception as e:
            print("出现异常：", e)
        self.asset_bim_asm_box_assName_loc.fill(assembly_name)
        self.asset_bim_asm_confirm_button()
